include ~/.cache/wal/colors-sway
include ~/.config/sway/$(hostname)/*
include /etc/sway/config.d/*

# Variables
set $mod Mod4
set $term foot
set $font JetBrainsMonoNerdFont
set $lock ~/.config/sway/scripts/lock
set $menu ~/.local/scripts/launcher $font $icons
set $screenshot ~/.local/scripts/wl-screenshot

set $tx $foreground
set $fg $color1
set $bg $background
set $ex $color15

# Colors                border  bg      text    indi     childborder
client.focused          $fg     $bg     $tx     $fg     $fg
client.focused_inactive $bg     $bg     $tx     $bg     $bg
client.unfocused        $bg     $bg     $tx     $bg     $bg
client.urgent           $ex     $ex     $tx     $ex     $ex

# workspaces
set $ws1   1
set $ws2   2
set $ws3   3
set $ws4   4
set $ws5   5
set $ws6   6
set $ws7   7
set $ws8   8
set $ws9   9
set $ws0   10

# Enable xwayland support
xwayland enable

# Font
font $font:8

# Window borders
default_border pixel 2
default_floating_border normal
hide_edge_borders smart

focus_follows_mouse no

smart_gaps on
gaps inner 8

# Autostart
exec --no-startup-id mako -c ~/.config/mako/config
exec --no-startup-id pipewire
exec --no-startup-id pipewire-pulse
exec --no-startup-id blueman-applet
exec --no-startup-id /usr/libexec/xdg-desktop-portal --replace
exec --no-startup-id /usr/libexec/xdg-desktop-portal-wlr
#exec --no-startup-id /usr/libexec/polkit-gnome-authentication-agent-1 

# Idle configuration
exec_always swayidle timeout 1200 "exec ~/.config/sway/scripts lock"

# Enable freesync
output * adaptive_sync on

# Input configuration
input * {
    xkb_layout us
    xkb_numlock enable
}

# Default workspaces for common programs
#assign [app_id="lutris"] $ws9


# Start some windows floating
for_window [app_id="mpv"] floating enable
for_window [class="Wine"] floating enable
for_window [app_id="lutris"] floating enable
for_window [class="imv"] floating enable # this still doesn't float for some reason

# Move and resize floating windows with mod+mouse
floating_modifier $mod normal

#################
### Shortcuts ###
#################
bindsym $mod+t exec $term
bindsym $mod+Shift+s exec $screenshot
bindsym $mod+d exec $menu

# Kills selected window
bindsym $mod+c kill bindsym

# Reloads sway config
bindsym $mod+Alt+Space reload

bindsym $mod+Escape exec $lock

# Notifications
bindsym Control+Space exec makoctl dismiss
bindsym Control+Shift+Space exec makoctl dismiss --all

# Multimedia
bindsym --locked XF86AudioRaiseVolume exec --no-startup-id pamixer -i 5
bindsym --locked XF86AudioLowerVolume exec --no-startup-id pamixer -d 5
bindsym --locked XF86AudioMute exec --no-startup-id pamixer -t
# Need a playerctl alternitive
#bindsym --locked XF86AudioPlay exec playerctl play-pause
#bindsym --locked XF86AudioNext exec playerctl next
#bindsym --locked XF86AudioPrev exec playerctl previous

# Brightness controls
bindsym --locked XF86MonBrightnessUp exec light -S "$(light -G | awk '{ print int(($1 + .72) * 1.4) }')"
bindsym --locked XF86MonBrightnessDown exec light -S "$(light -G | awk '{ print int($1 / 1.4) }')"

# Move your focus around
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# Same but with vim like binds
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

# Move the focused window with the same, but add Shift
bindsym $mod+Alt+Left move left
bindsym $mod+Alt+Down move down
bindsym $mod+Alt+Up move up
bindsym $mod+Alt+Right move right

# Same but with vim like binds
bindsym $mod+Alt+h move left
bindsym $mod+Alt+j move down
bindsym $mod+Alt+k move up
bindsym $mod+Alt+l move right

# switch to workspace
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10

# Switch the current workspace between different layout styles
bindsym $mod+o layout stacking
bindsym $mod+p layout toggle split

# Make the current focus fullscreen
bindsym $mod+f fullscreen

# Toggle the current focus between tiling and floating mode
bindsym $mod+space floating toggle

# Swap focus between the tiling area and the floating area
bindsym $mod+Ctrl+space focus mode_toggle

# move focus to the parent window
bindsym $mod+a focus parent

# Modes
mode "resize" {
    bindsym Left resize shrink width 25px
    bindsym Up resize shrink height 25px
    bindsym Down resize grow height 25px
    bindsym Right resize grow width 25px

    # return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"

exec_always ~/.config/waybar/launch.sh
